{extend name="base" /} {block name="body"}
<div class="layui-body">
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="">
				<a href="{:url('order/index')}">订单管理</a>
			</li>
			<li class="layui-this">订单详情</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<form class="layui-form form-container" action="{:url('order/info')}" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label">订单ID</label>
						<div class="layui-input-block">
							<input type="text" name="order_id" value="{$order.order_id}" required lay-verify="required" placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">物流号</label>
						<div class="layui-input-block">
							<input type="text" name="order_sn" value="{$order.order_sn}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">用户编号</label>
						<div class="layui-input-block">
							<input type="text" name="user_id" value="{$order.user_id}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">商品总价</label>
						<div class="layui-input-block">
							<input type="text" name="total_price" value="{$order.total_price}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">支付价格</label>
						<div class="layui-input-block">
							<input type="text" name="pay_price" value="{$order.pay_price}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">下单时间</label>
						<div class="layui-input-block">
							<input type="text" name="add_time" value="{$order.add_time}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">支付时间</label>
						<div class="layui-input-block">
							<input type="text" name="pay_time" value="{$order.pay_time}" readonly placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">收货地址：</label>
						<div class="layui-input-block">
							<input type="text" id='address' name="address" value="{$order.address}"  placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<input type="hidden" name="id" value="{$order.order_id}">
						</div>
					</div>
					{if $order.status == 2}
					<div class="layui-form-item">
						<label class="layui-form-label">物流名称：</label>
						<div class="layui-input-block">
							<input type="text" id='shipping_name' name="shipping_name" value=""  placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">物流号：</label>
						<div class="layui-input-block">
							<input type="text" id='shipping_code' name="shipping_code" value=""  placeholder="" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
						    <button type="button" onclick="shipments_order()" class="layui-btn layui-btn-radius">确认发货</button>
						</div>
					</div>
					{/if}
				</form>
			</div>
		</div>
	</div>
</div>
<script>
	// 定义全局JS变量
	var GV = {
		current_controller: "{$controller}/index"
	};
</script>
{/block}
{block name='script'}
<script>
	function shipments_order(){
		if($("#shipping_code").val()==""){
			layer.msg("请输入物流编号");
			return ;
		}
		$.ajax({
			url: "{:url('order/shipments_order')}",
			data: {
				order_id		: "{$order.order_id}",
				shipping_name	: $('#shipping_name').val(),
				shipping_code	: $('#shipping_code').val()
			},
			success: function(data) {
				layer.msg(data.msg, {
				  icon: 1,
				  time: 1500 //2秒关闭（如果不配置，默认是3秒）
				}, function(){
					  if(data.code == 200) {
							location.href = data.url
					  }
				});
			}
		})
}
</script>
{/block}